<template>
  <div class="star">
    <div class="newText">下厨房的厨友们</div>
    <div class="all">更多</div>
    <div class="starbox">
      <div
        v-for="(item, index) in fans"
        class="sbox"
        :data-userid="userid[index]"
      >
        <img :src="touxiang[index]" alt="" class="img" @click="usergo" />
        <div class="username">{{ username[index] }}</div>
        <div class="fans">{{ fans[index] }}&nbsp&nbsp关注</div>
        <div class="opus">{{ opus[index] }}个作品</div>
        <div class="xian"></div>
        <div class="guanzhu">关注</div>
      </div>
      <div class="all2">查看更多</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: [],
      touxiang: [],
      fans: [],
      opus: [],
      userid: [],
    };
  },
  async mounted() {
    var touxiang = [];
    var username = [];
    var fans = [];
    var userid = [];
    this.$axios("/zztz/star").then((res) => {
      // console.log(res);
      res.data.map((el) => {
        touxiang.push(el.touxiang);
        username.push(el.username);
        fans.push(el.fans);
        userid.push(el.id);
      });
      this.username = username;
      this.touxiang = touxiang;
      this.fans = fans;
      this.userid = userid;
    });
    this.$axios("/zztz/opus").then((res) => {
      this.opus = res.data;
    });
  },
  methods: {
    usergo(e) {
      console.log(e.target.parentNode.dataset.userid, 11111111111111);
      this.$router.push({
        path: "/zlx",
        query: { userid: e.target.parentNode.dataset.userid },
      });
    },
  },
};
</script>

<style scoped="scoped">
.star {
  width: 300px;
  height: 716px;
  position: absolute;
  right: 20px;
  top: 1790px;
  overflow: hidden;
  /* background-color: palegreen; */
}
.newText {
  font-size: 20px;
  font-weight: 700;
  color: #c0ae7d;
}
.all {
  color: #dd3915;
  position: absolute;
  left: 158px;
  top: 5px;
  cursor: pointer;
}
.all:hover {
  background-color: #dd3915;
  color: white;
}
.xian {
  width: 300px;
  height: 1px;
  background-color: #f3f3f3;
  position: absolute;
  bottom: -20px;
}
.sbox {
  width: 300px;
  height: 60px;
  margin-bottom: 30px;
  margin-top: 20px;
  position: relative;
}
.sbox img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
}
.sbox img:hover {
  opacity: 0.8;
}
.username {
  position: absolute;
  left: 79px;
  top: 2px;
  cursor: pointer;
}
.username:hover {
  color: orangered;
}
.fans {
  position: absolute;
  left: 79px;
  top: 23px;
  font-size: 12px;
  color: #909090;
}
.opus {
  position: absolute;
  left: 79px;
  top: 42px;
  font-size: 12px;
  color: #909090;
}
.guanzhu {
  width: 86px;
  height: 40px;
  font-size: 15px;
  text-align: center;
  line-height: 40px;
  cursor: pointer;
  color: white;
  background-color: #dd3915;
  position: absolute;
  right: 0;
  top: 0;
}
.all2 {
  color: #dd3915;
  position: absolute;
  left: 131px;
  bottom: 10px;
  cursor: pointer;
}
.all2:hover {
  background-color: #dd3915;
  color: white;
}
</style>